package com.summer.springboot_order_rabbitmq_consumer.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

@Configuration
public class TTLRabbitConfiguration {
    //声明fanout交换机
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("ttl_direct_order_exchange",true,false);
    }
    //队列的过期时间
    //声明队列
    @Bean
    public Queue ttldirectsmsQueue(){
       Map<String, Object> args = new HashMap<>();
       args.put("x-message-ttl",5000);
        return new Queue("ttl.direct.queue",true);
    }

    @Bean
    public Binding directemailBinding(){
        return BindingBuilder.bind(ttldirectsmsQueue()).to(directExchange()).with("ttl");
    }
}
